import Vue from 'vue'
import Router from 'vue-router'
import Main from './views/Main.vue'

import CategoryEdit from './views/CategoryEdit.vue'
import CategoryList from './views/CategoryList.vue'
import ItemsEdit from './views/ItemsEdit.vue'
import ItemsList from './views/ItemsList.vue'
import HeroEdit from './views/HeroEdit.vue'
import HeroList from './views/HeroList.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'main',
      component: Main,
      children: [
        { path: '/categories/create', component: CategoryEdit },
        // 两个不同组件使用同一个组件，加上特殊参数 props: true 表示把当前路由的任何参数都注入到当前组件里面，
        // 在CategoryEdit 组件就可以直接使用一个变量
        { path: '/categories/edit/:id', component: CategoryEdit, props: true },
        { path: '/categories/list', component: CategoryList },

        { path: '/items/create', component: ItemsEdit },
        { path: '/items/edit/:id', component: ItemsEdit, props: true },
        { path: '/items/list', component:ItemsList },
        // 英雄
        { path: '/heros/create', component: HeroEdit },
        { path: '/heros/edit/:id', component: HeroEdit, props: true },
        { path: '/heros/list', component:HeroList },
      ]
    },

  ]
})
